package com.lx.chong.repository;

import com.lx.chong.model.Department;
import com.lx.chong.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author chong
 * @create 2019/5/15
 * Desc: 部门
 */
public interface DepartmentRepository extends JpaRepository<Department, Long>, JpaSpecificationExecutor<Department> {
    /**
     * 获取部门下拉
     * @param ifDelete
     * @param useMark
     * @return
     */
    List<Department> findAllByIfDeleteAndUseMark(Integer ifDelete,Integer useMark);



    /**
     * 分页查询
     * @param startNum
     * @param total
     * @return
     */
    @Query(value = "SELECT  * FROM department WHERE IfDelete =0 order by  addDateTime desc LIMIT ?1,?2",nativeQuery = true)
    List<Department> getDepListPage(Integer startNum, Integer total);


    @Query(value = "SELECT count(1) FROM department WHERE IfDelete =0 ",nativeQuery = true)
    Long getDepCount();
}
